import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;


public class Ball {
	int x;
	int y;
	int dy = 0;
	int dx = 0;
	final int RIGHT = 0;
	final int LEFT = 1;
	int dir = RIGHT;
	
	boolean player = false;
	
	boolean fg = true;
	public Ball(boolean fg){
		this.fg = fg;
	}
	
	public Ball(int x, int y){
			this.x = x;
			this.y = y;
			int randDir = (int)(Math.random()*10);
			if(randDir < 3){
				dir = RIGHT;
			}else{
				dir = LEFT;
			}
			if(dir == LEFT){
				this.dx = -Math.abs(dx);
				while(dx-1 > - 9){
					dx -=1;
				}
				while(dy-1 > -3){
					dy -=1;
				}
				
	
			}else if(dir == RIGHT){
				this.dx = Math.abs(dx);
				while (dx + 1< 9){
					dx+=1;
				}
				while(dy+1 < 3){
					dy +=1;
				}
	
			}
		
	}
	
	public void paintComponent(Graphics g){
		Graphics2D po = (Graphics2D)g;
		
		po.setColor(Color.white);
		if(fg){
			po.fillOval(this.x , this.y , 9*2, 9*2);
		}
		
	}
	
	
	
	public void update(){
		if(fg){
			if(y>Game.getHEIGHT() - 45){
				dy = -dy;
			}
			if(y<0){
				dy = -dy;
			}
			y+= dy;
			x+= dx;
		}else{
			dy = 0;
			dx = 0;
		}
		
	}
	
}
